package applicationServer.logic;

import java.util.ArrayList;

import javax.sip.address.Address;

public class UserInfo implements StreamerInfo{

	String _id = null;
	String _name = null;
	String _address = null;
	int _port = 0;
	Address _addressheader = null;
	ArrayList <String> services = null;
	
	
	public UserInfo(String id, Address add, String serv){
		this._id = id;		
		_addressheader = add;
		_name = _addressheader.getURI().toString().substring(0,_addressheader.getURI().toString().indexOf("@"));
		_address = _addressheader.getURI().toString().substring(_addressheader.getURI().toString().indexOf("@")+1, _addressheader.getURI().toString().indexOf(":"));
		_port = Integer.parseInt(_addressheader.getURI().toString().substring(_addressheader.getURI().toString().indexOf(":")+1));
		services = new ArrayList<String>();
		services.add(serv);
	}
	
	public UserInfo(String id,Address add, ArrayList <String> servs){
		this._id = id;
		_addressheader = add;
		services = servs;
	}
	
	
	public String get_id() {
		return _id;
	}

	public void set_id(String id) {
		this._id = id;
	}

	public void addMedia (String media){
		services.add(media.toString());
	}

	public ArrayList<String> getServices() {
		return services;
	}

	public void setServices(ArrayList<String> services) {
		this.services = services;
	}

	public boolean isReceiving(String mediaName) {
		// TODO Auto-generated method stub
		return services.contains(mediaName);
	}

	public String get_address() {
		// TODO Auto-generated method stub
		return _address;
	}

	public Address get_addressheader() {
		// TODO Auto-generated method stub
		return _addressheader;
	}

	public int get_port() {
		// TODO Auto-generated method stub
		return _port;
	}

	public void set_address(String address) {
		// TODO Auto-generated method stub
		_address = address;
	}

	public void set_addressheader(Address addressheader) {
		// TODO Auto-generated method stub
		_addressheader = addressheader;
	}

	public void set_port(int port) {
		// TODO Auto-generated method stub
		_port = port;
	}

	public String get_name() {
		return _name;
	}

	public void set_name(String name) {
		_name = name;
		
	}
}